home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / mg2a_src.zip / TTYIO.C < prev    next >
C/C++ Source or Header  |  1991-02-19  |  2KB  |  101 lines

  1. /*
  2.  * Name:    Mg 2b
  3.  *        MSDOS terminal I/O (TurboC 1.5)
  4.  *
  5.  * The functions in this file
  6.  * negotiate with the operating system for
  7.  * keyboard characters, and write characters to
  8.  * the display
  9.  *
  10.  * This version goes along with tty/ibmbios/tty.c.
  11.  * Terminal size is determined there, rather than here.
  12.  */
  13. #include    "def.h"
  14.  
  15. #include    <stdio.h>
  16. #include    <fcntl.h>
  17. #include    <signal.h>
  18.  
  19. void interrupt donothing();
  20.  
  21. static int ttyactivep = FALSE;        /* terminal in editor mode?    */
  22.  
  23. int    nrow;                /* Terminal size, rows.        */
  24. int    ncol;                /* Terminal size, columns.    */
  25.  
  26. /*
  27.  * This function gets called once, to set up
  28.  * the terminal channel.  This is essentially a no-op
  29.  * on msdos, since I/O will all be done via bios calls.
  30.  */
  31. ttopen()
  32. {
  33.     if (ttyactivep)
  34.         return;
  35.  
  36.     signal(SIGINT, SIG_IGN);
  37.  
  38.     setvect(0x23, donothing);
  39.  
  40.     nrow = 25;            /* initial guess */
  41.     ncol = 80;
  42.  
  43.     ttyactivep = TRUE;
  44. }
  45.  
  46. /*
  47.  * This function gets called just
  48.  * before we go back home to the shell. Another
  49.  * MSDOS no_op.
  50.  */
  51. ttclose()
  52. {
  53.     if(!ttyactivep)
  54.         return;
  55.     ttyactivep = FALSE;
  56. }
  57.  
  58. /********************************************************************/
  59. /* ttputc, ttgetc & typeahead have been deleted from this file, and */
  60. /* moved into the tty specific code.  There is no operating-system  */
  61. /* generic way to do these                                          */
  62. /********************************************************************/
  63.  
  64. /*
  65.  * Flush output.  This function is a no-op
  66.  */
  67. ttflush()
  68. {
  69. }
  70.  
  71. /*
  72.  * panic:  print error and die, leaving core file.
  73.  */
  74. panic(s)
  75. char *s;
  76. {
  77.     fprintf(stderr, "%s\r\n", s);
  78. #ifdef SYSCLEANUP
  79.     SYSCLEANUP;
  80. #endif
  81.     exit(1);
  82. }
  83.  
  84.  
  85. /*
  86. ** This should check the size of the window, and reset if needed.
  87. */
  88.  
  89. setttysize()
  90. {
  91.     nrow = 25;
  92.     ncol = 80;
  93. }
  94.  
  95.  
  96. void interrupt donothing()
  97.     {
  98.     return;    /* continue program */
  99.     }
  100.  
  101.